﻿local QI = DailyIntake.QuestItems;
local Localize = DailyIntake.Localize;

--------------------------------------------------------------------------------
-- Sons of Hodir quest items
--------------------------------------------------------------------------------

-- Add item: Spear of Hodir; http://www.wowhead.com/?item=42769
local function SpearOfHodir()
    return UnitOnTaxi("player") ~= 1
        
        -- must target Wild Wyrm; http://www.wowhead.com/?npc=30275
        and QI.UnitIsEntity("target", 30275, QI.Entity.Vehicle)
        
        -- Wild Wyrm must be alive
        and not UnitIsDead("target")
        
        -- must not be tapped by other players
        and not QI.UnitIsTappedByOtherPlayer("target")
        
        -- must not have completed quest objective yet
        and not QI.QuestIsDone(13003);
end
QI.RegisterQuestItem(42769, QI.Priority.Normal, SpearOfHodir);

-- Add item: Horn of Hodir; http://www.wowhead.com/?item=42164
local function HornOfHodir()
    return UnitOnTaxi("player") ~= 1
        
        -- must target one of the following:
        -- Restless Frostborn Warrior; http://www.wowhead.com/?npc=30135
        -- Restless Frostborn Ghost; http://www.wowhead.com/?npc=30144
        -- Niffelem Forefather; http://www.wowhead.com/?npc=29974
        and (QI.UnitIsEntity("target", 30135, QI.Entity.Mob)
          or QI.UnitIsEntity("target", 30144, QI.Entity.Mob)
          or QI.UnitIsEntity("target", 29974, QI.Entity.Mob)
          )
        
        -- the target must be dead
        and UnitIsDead("target") == 1
        
        -- must not be tapped by other players
        and not QI.UnitIsTappedByOtherPlayer("target")
        
        -- must not have completed quest yet
        and not QI.QuestIsDone(12977);
end
QI.RegisterQuestItem(42164, QI.Priority.High, HornOfHodir);

-- Add item: Arngrim's Tooth; http://www.wowhead.com/?item=42774
local function ArngrimsTooth()
    return UnitOnTaxi("player") ~= 1
        
        -- must target Roaming Jormungar; http://www.wowhead.com/?npc=30275
        and QI.UnitIsEntity("target", 30422, QI.Entity.Mob)
        
        -- Roaming Jormungar must be alive
        and not UnitIsDead("target")
        
        -- must not be tapped by other players
        and not QI.UnitIsTappedByOtherPlayer("target")
        
        -- must not have completed quest objective yet
        and not QI.QuestIsDone(13046);
end;
QI.RegisterQuestItem(42774, QI.Priority.High, ArngrimsTooth);

-- Add item: Ethereal Worg's Fang; http://www.wowhead.com/?item=42479
local function EtherealWorgsFang()
    return UnitOnTaxi("player") ~= 1
        
        -- must be in propper spot
        and QI.PlayerIsCloseTo(0.57232767343521, 0.64025062322617, 0.00223)
        
        -- must not have completed quest objective yet
        and not QI.QuestIsDone(12994);
end;
QI.RegisterQuestItem(42479, QI.Priority.Normal, EtherealWorgsFang);

-- Add item: Essence of Ice; http://www.wowhead.com/?item=42246
local function EssenceOfIce()
    return UnitOnTaxi("player") ~= 1
        
        -- must be in propper subzone
        and GetSubZoneText() == Localize("Fjorn's Anvil")
        
        -- must not have completed quest objective yet
        and not QI.QuestIsDone(12981);
end;
QI.RegisterQuestItem(42246, QI.Priority.Normal, EssenceOfIce);

-- Add item: Goblin Chisel; http://www.wowhead.com/?item=45281
local function GoblinChisel()
    return UnitOnTaxi("player") ~= 1
        
        -- must be in propper subzone
        and (GetSubZoneText() == Localize("Foot Steppes") or GetSubZoneText() == Localize("Inventor's Library"))
        
        -- must not have completed quest objective yet
        and not QI.QuestIsDone(13681);
end;
QI.RegisterQuestItem(45281, QI.Priority.Normal, GoblinChisel);

-- Add item: Disciplining Rod; http://www.wowhead.com/?item=42837
local function DiscipliningRod()
    return UnitOnTaxi("player") ~= 1
        
        -- must target Exhausted Vrykul
        and QI.UnitIsEntity("target", 30146, QI.Entity.Mob)
        
        -- Roaming Jormungar must be alive
        and not UnitIsDead("target")
        
        -- must not be tapped by other players
        and not QI.UnitIsTappedByOtherPlayer("target")
        
        -- must not have completed quest objective yet
        and not QI.QuestObjectiveIsDone(13422, 1);
end;
QI.RegisterQuestItem(42837, QI.Priority.High, DiscipliningRod);

-- Add item: Improved Land Mines; http://www.wowhead.com/?item=40676
local function ImprovedLandMines()
    return not UnitOnTaxi("player")
        
        -- must be in propper subzone
        and GetZoneText() == Localize("The Storm Peaks")
        and GetSubZoneText() == Localize("Garm's Bane")
        
        -- must not have completed quest objective yet
        and not QI.QuestIsDone(12833); -- Overstock (http://www.wowhead.com/?quest=12833)
end;
QI.RegisterQuestItem(40676, QI.Priority.High, ImprovedLandMines);

-- Add item: Reins of the Icemaw Matriarch; http://www.wowhead.com/?item=42499
local function ReinsOfTheIcemawMatriarch()
    return not UnitOnTaxi("player")
        
        -- must be in propper subzone
        and GetZoneText() == Localize("The Storm Peaks")
        and GetSubZoneText() == Localize("Pit of the Fang")
        
        -- must not have completed quest objective yet
        and not QI.QuestIsDone(13424); -- Overstock (http://www.wowhead.com/?quest=13424)
end;
QI.RegisterQuestItem(42499, QI.Priority.High, ReinsOfTheIcemawMatriarch);

-- =============================================================
-- Added by LaoTseu
-- =============================================================

local function WeightedNet()
	return not UnitOnTaxi("player")
        
	-- must be in propper zone
	and GetZoneText() == Localize("The Storm Peaks")

	-- must target a Snowblind Follower http://www.wowhead.com/?npc=29618
	and QI.UnitIsEntity("target", 29618, QI.Entity.Mob)

	-- must not have completed quest objective yet
	-- Alliance: http://www.wowhead.com/?quest=14090
	-- Horde:	 http://www.wowhead.com/?quest=14141
	and (    (UnitFactionGroup("player") == "Alliance" and not QI.QuestIsDone(14090)) 
			or (UnitFactionGroup("player") == "Horde"    and not QI.QuestIsDone(14141)));
end;
QI.RegisterQuestItem(46885, QI.Priority.Normal, WeightedNet);

-- Add item: Earthshaker Drum; http://www.wowhead.com/?item=46893
QI.RegisterQuestItem(46893, QI.Priority.Normal, function()
	return not UnitOnTaxi("player")
        
	-- must be in propper zone and subzone
	and GetZoneText() == Localize("The Storm Peaks")
	and GetSubZoneText() == "The Foot Steppes"

	-- must not have completed quest objective yet
	-- Alliance: http://www.wowhead.com/?quest=14076
	-- Horde:	 http://www.wowhead.com/?quest=14092
	and (    (UnitFactionGroup("player") == "Alliance" and not QI.QuestIsDone(14076)) 
			or (UnitFactionGroup("player") == "Horde"    and not QI.QuestIsDone(14092)));
end);
